package com.chagee.store.operation.api.bo;

import com.alibaba.fastjson.JSONObject;
import lombok.*;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.*;

/**
 *
 * @Author : hk
 * @Date : 2025/2/25
 */

@Data
@Builder
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class TagJsonBO implements Serializable {

	private static final long serialVersionUID = -2444049460726643955L;
	private Set<String> tagCodes;

	public TagJsonBO(Collection<String> tagCodes) {
		if (CollectionUtils.isEmpty(tagCodes)) {
			this.tagCodes = Collections.emptySet();
			return;
		}
		this.tagCodes = new HashSet<>(tagCodes);
	}

	public static final TagJsonBO EMPTY = new TagJsonBO(Collections.emptyList());

	public String toJsonString() {
		return JSONObject.toJSON(this).toString();
	}

	public Set<String> getTagCodes() {
		return tagCodes == null ? Collections.emptySet() : tagCodes;
	}


}
